//package com.v2.activity;
//
//import android.content.Intent;
//import android.text.Editable;
//import android.text.InputType;
//import android.text.TextUtils;
//
//import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
//import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView;
//import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView;
//import com.v2.utils.TSP;
//import com.v2.utils.TToast;
//import com.zou.lotterylucky.Constants;
//import com.zou.lotterylucky.R;
//import com.zou.lotterylucky.databinding.ActivitySettingOuterBinding;
//
//public class SettingOuterActivity extends BaseActivity<ActivitySettingOuterBinding> {
//
//    private QMUICommonListItemView item2, item3;
//
//    @Override
//    protected int layoutId() {
//        return R.layout.activity_setting_outer;
//    }
//
//    @Override
//    protected void onCreate() {
//        mBinding.topbar.setTitle(R.string.waibushezhi);
//        mBinding.topbar.addLeftBackImageButton().setOnClickListener(v -> onBackPressed());
//
//        String storeName = TSP.getInstance().getString("store_name", "Lucky");
//        mBinding.storeNameTxt.setText(storeName);
//
//        mBinding.saveBtn.setOnClickListener(v -> {
//            if (TextUtils.isEmpty(mBinding.storeNameTxt.getText().toString())) {
//                TToast.show(R.string.input_store);
//                return;
//            }
//
//            TSP.getInstance().setString("store_name", mBinding.storeNameTxt.getText().toString());
//            TToast.show("保存成功");
//        });
//
//        item2 = mBinding.qlv.createItemView(getString(R.string.dayinzhangshu));
//        item2.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON);
//        item3 = mBinding.qlv.createItemView(getString(R.string.chooseLang));
//        item3.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON);
//
//
//        QMUIGroupListView.newSection(this).addItemView(item2, v -> {
//            QMUIDialog.EditTextDialogBuilder builder = new QMUIDialog.EditTextDialogBuilder(this);
//            builder.setTitle(getString(R.string.shezhi));
//            builder.setPlaceholder(getString(R.string.qingshurumima));
//            builder.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
//            builder.addAction(R.string.cancel, (dialog, index) -> dialog.dismiss());
//            builder.addAction(R.string.confirm, (dialog, index) -> {
//                Editable text = builder.getEditText().getText();
//                if (!TextUtils.isEmpty(text)) {
//                    String psd = TSP.getInstance().getString(Constants.SP_PASSWORD, Constants.print_psd);
//                    if (psd.equals(text.toString())) {
//                        selectPrintSize();
//                        dialog.dismiss();
//                    } else {
//                        TToast.show(getString(R.string.password_error));
//                    }
//                } else {
//                    TToast.show(getString(R.string.please_input_password));
//                }
//            });
//            builder.create().show();
//        }).addItemView(item3, v -> {
//            int current = TSP.getInstance().getInt(Constants.SP_Lang, 1);
//            String[] opts = {"Spanish", "中文", "English"};
//            QMUIDialog.CheckableDialogBuilder builder = new QMUIDialog.CheckableDialogBuilder(this);
//            builder.setCheckedIndex(current);
//            builder.addItems(opts, (dialog, which) -> {
//                if (which != current) {
//                    dialog.dismiss();
//                    TSP.getInstance().setInt(Constants.SP_Lang, which);
//                    Intent intent = new Intent(this, MainActivity.class);
//                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
//                    startActivity(intent);
//                    android.os.Process.killProcess(android.os.Process.myPid());
//                    System.exit(0);
//                }
//            });
//            builder.create().show();
//        }).addTo(mBinding.qlv);
//
//        initData();
//    }
//
//
//    private void selectPrintSize() {
//        int current = TSP.getInstance().getInt(Constants.SP_DaYinZhangShu, 0);
//        String[] opts = {getString(R.string.dayinkehu), getString(R.string.dayinkehujiacungen)};
//        QMUIDialog.CheckableDialogBuilder builder = new QMUIDialog.CheckableDialogBuilder(this);
//        builder.setCheckedIndex(current);
//        builder.addItems(opts, (dialog, which) -> {
//            if (which != current) {
//                TSP.getInstance().setInt(Constants.SP_DaYinZhangShu, which);
//                dialog.dismiss();
//                item2.setDetailText(which == 0 ? getString(R.string.dayinkehu) : getString(R.string.dayinkehujiacungen));
//            } else {
//                dialog.dismiss();
//            }
//        });
//        builder.create().show();
//    }
//
//    private void initData() {
//        int num = TSP.getInstance().getInt(Constants.SP_DaYinZhangShu, 0);
//        item2.setDetailText(num == 0 ? getString(R.string.dayinkehu) : getString(R.string.dayinkehujiacungen));
//
//
//    }
//}
